<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>深入理解 Elasticsearch：分布式搜索引擎的架构与实践</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 1px solid rgba(255, 255, 255, 0.1);
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            border-color: rgba(102, 126, 234, 0.3);
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 30px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
            border-left: 4px solid #667eea;
            padding: 20px;
            border-radius: 8px;
            margin: 20px 0;
        }
        
        .code-inline {
            background: rgba(102, 126, 234, 0.1);
            padding: 2px 8px;
            border-radius: 4px;
            font-family: 'Courier New', monospace;
            font-size: 0.9em;
            color: #5a67d8;
        }
        
        .drop-cap {
            float: left;
            font-size: 4em;
            line-height: 0.8;
            margin: 0.1em 0.1em 0 0;
            font-weight: 700;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-family: 'Noto Serif SC', serif;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 40px 0;
        }
        
        .feature-icon {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 50%;
            color: white;
            font-size: 24px;
            margin-bottom: 20px;
        }
        
        .timeline-item {
            position: relative;
            padding-left: 40px;
            margin-bottom: 30px;
        }
        
        .timeline-item::before {
            content: '';
            position: absolute;
            left: 10px;
            top: 5px;
            width: 10px;
            height: 10px;
            background: #667eea;
            border-radius: 50%;
        }
        
        .timeline-item::after {
            content: '';
            position: absolute;
            left: 14px;
            top: 15px;
            width: 2px;
            height: calc(100% + 20px);
            background: rgba(102, 126, 234, 0.3);
        }
        
        .timeline-item:last-child::after {
            display: none;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6">
                    深入理解 <span class="text-yellow-300">Elasticsearch</span>
                </h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90">
                    分布式搜索引擎的架构与实践
                </p>
                <div class="flex justify-center space-x-4">
                    <div class="bg-white bg-opacity-20 rounded-lg px-6 py-3">
                        <i class="fas fa-server mr-2"></i>
                        分布式架构
                    </div>
                    <div class="bg-white bg-opacity-20 rounded-lg px-6 py-3">
                        <i class="fas fa-search mr-2"></i>
                        实时搜索
                    </div>
                    <div class="bg-white bg-opacity-20 rounded-lg px-6 py-3">
                        <i class="fas fa-chart-line mr-2"></i>
                        数据分析
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Introduction -->
    <section class="py-16">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto">
                <div class="card-hover rounded-xl p-8">
                    <p class="text-lg leading-relaxed text-gray-700">
                        <span class="drop-cap">E</span>lasticsearch 是一个分布式、可扩展的搜索和分析引擎，广泛应用于日志分析、全文搜索、实时数据分析等场景。其强大的功能和灵活的架构使其成为现代数据驱动应用的核心组件之一。
                    </p>
                </div>
            </div>
        </div>
    </section>

    <!-- Core Concepts -->
    <section class="py-16">
        <div class="container mx-auto px-6">
            <div class="max-w-6xl mx-auto">
                <h2 class="text-4xl font-bold mb-12 text-center text-gray-800">
                    <i class="fas fa-cube mr-3 text-purple-600"></i>核心概念
                </h2>
                
                <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6 mb-12">
                    <div class="card-hover rounded-xl p-6">
                        <div class="feature-icon">
                            <i class="fas fa-database"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-3 text-gray-800">索引（Index）</h3>
                        <p class="text-gray-600">类似于数据库中的表，用于存储相关文档。每个索引都有自己的设置和映射。</p>
                    </div>
                    
                    <div class="card-hover rounded-xl p-6">
                        <div class="feature-icon">
                            <i class="fas fa-file-alt"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-3 text-gray-800">文档（Document）</h3>
                        <p class="text-gray-600">索引中的基本数据单元，通常以 JSON 格式存储，包含多个字段。</p>
                    </div>
                    
                    <div class="card-hover rounded-xl p-6">
                        <div class="feature-icon">
                            <i class="fas fa-puzzle-piece"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-3 text-gray-800">分片（Shard）</h3>
                        <p class="text-gray-600">索引被分成多个分片，分布在不同的节点上，实现数据的分布式存储。</p>
                    </div>
                    
                    <div class="card-hover rounded-xl p-6">
                        <div class="feature-icon">
                            <i class="fas fa-copy"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-3 text-gray-800">副本（Replica）</h3>
                        <p class="text-gray-600">每个分片可以有多个副本，提高数据的可用性和查询性能。</p>
                    </div>
                    
                    <div class="card-hover rounded-xl p-6">
                        <div class="feature-icon">
                            <i class="fas fa-server"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-3 text-gray-800">节点（Node）</h3>
                        <p class="text-gray-600">Elasticsearch 集群中的一个实例，负责存储数据和执行查询。</p>
                    </div>
                    
                    <div class="card-hover rounded-xl p-6">
                        <div class="feature-icon">
                            <i class="fas fa-network-wired"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-3 text-gray-800">集群（Cluster）</h3>
                        <p class="text-gray-600">由多个节点组成的集合，共同存储和查询数据。</p>
                    </div>
                </div>

                <!-- Architecture Diagram -->
                <div class="card-hover rounded-xl p-8">
                    <h3 class="text-2xl font-bold mb-6 text-center text-gray-800">Elasticsearch 架构图</h3>
                    <div class="mermaid">
                        graph TB
                            subgraph "Elasticsearch Cluster"
                                subgraph "Master Nodes"
                                    M1[Master Node 1]
                                    M2[Master Node 2]
                                end
                                
                                subgraph "Data Nodes"
                                    D1[Data Node 1]
                                    D2[Data Node 2]
                                    D3[Data Node 3]
                                end
                                
                                subgraph "Coordinating Nodes"
                                    C1[Coordinating Node 1]
                                    C2[Coordinating Node 2]
                                end
                            end
                            
                            Client[客户端] --> C1
                            Client --> C2
                            C1 --> D1
                            C1 --> D2
                            C1 --> D3
                            C2 --> D1
                            C2 --> D2
                            C2 --> D3
                            M1 -.-> D1
                            M1 -.-> D2
                            M1 -.-> D3
                            M2 -.-> D1
                            M2 -.-> D2
                            M2 -.-> D3
                            
                            style M1 fill:#667eea,stroke:#fff,color:#fff
                            style M2 fill:#667eea,stroke:#fff,color:#fff
                            style D1 fill:#48bb78,stroke:#fff,color:#fff
                            style D2 fill:#48bb78,stroke:#fff,color:#fff
                            style D3 fill:#48bb78,stroke:#fff,color:#fff
                            style C1 fill:#ed8936,stroke:#fff,color:#fff
                            style C2 fill:#ed8936,stroke:#fff,color:#fff
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Architecture Design -->
    <section class="py-16 bg-gray-50">
        <div class="container mx-auto px-6">
            <div class="max-w-6xl mx-auto">
                <h2 class="text-4xl font-bold mb-12 text-center text-gray-800">
                    <i class="fas fa-sitemap mr-3 text-purple-600"></i>架构设计
                </h2>
                
                <div class="grid md:grid-cols-2 gap-8">
                    <div class="card-hover rounded-xl p-8">
                        <h3 class="section-title text-2xl font-bold mb-6 text-gray-800">分布式架构</h3>
                        <p class="text-gray-600 mb-4">
                            Elasticsearch 采用分布式架构，数据被分成多个分片，分布在不同的节点上。这种设计不仅提高了数据的存储能力，还实现了查询的并行处理，显著提升了性能。
                        </p>
                        <div class="highlight-box">
                            <h4 class="font-bold mb-2 text-gray-800">
                                <i class="fas fa-layer-group mr-2 text-purple-600"></i>分片与副本
                            </h4>
                            <ul class="space-y-2 text-gray-600">
                                <li><i class="fas fa-check-circle mr-2 text-green-500"></i>分片数量在创建索引时指定</li>
                                <li><i class="fas fa-check-circle mr-2 text-green-500"></i>副本数量可以动态调整</li>
                                <li><i class="fas fa-check-circle mr-2 text-green-500"></i>副本分担查询负载</li>
                            </ul>
                        </div>
                    </div>
                    
                    <div class="card-hover rounded-xl p-8">
                        <h3 class="section-title text-2xl font-bold mb-6 text-gray-800">节点角色</h3>
                        <div class="space-y-4">
                            <div class="timeline-item">
                                <h4 class="font-bold text-gray-800">